<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function one() {
            setTimeout(() => {
                console.log(1);
                iterator.next()

            }, 1000);
        }
        function two() {
            setTimeout(() => {
                console.log(2);
                iterator.next()

            }, 2000);
        }
        function three() {
            setTimeout(() => {
                console.log(3);
                iterator.next()

            }, 3000);
        }
        function* fn() {
            yield one()
            yield two()
            yield three()
        }
        let iterator = fn()
        iterator.next()
    </script>
</body>

</html>